package com.todo.sight.infrastructure.convert;


import com.todo.sight.infrastructure.entity.domain.SightInfoDO;
import com.todo.sight.infrastructure.entity.po.SightBasePO;
import com.todo.sight.infrastructure.entity.po.SightDetailPO;

import java.util.Date;

/**
 * @author zhangwenxiang
 * @date 2024/3/29 00:20
 * @description
 */
public class SightConvert {

    public static SightInfoDO convertToSightInfoDO(SightBasePO sightBasePO, SightDetailPO sightDetailPO) {
        if (sightBasePO == null || sightDetailPO == null) {
            return null;
        }
        SightInfoDO sightInfoDO = new SightInfoDO();
        sightInfoDO.setSightBase(SightConvert.convertToSightBaseBO(sightBasePO));
        sightInfoDO.setSightDetail(SightConvert.convertToSightDetailBO(sightDetailPO));
        sightInfoDO.setId(sightBasePO.getId());
        sightInfoDO.setCreateUser(sightBasePO.getCreateUser());
        sightInfoDO.setLastUpdateUser(sightBasePO.getLastUpdateUser());
        return sightInfoDO;
    }

    private static SightInfoDO.SightDetail convertToSightDetailBO(SightDetailPO sightDetailPO) {
        if (sightDetailPO == null) {
            return null;
        }
        SightInfoDO.SightDetail sightDetail = new SightInfoDO.SightDetail();
        sightDetail.setDesc(sightDetailPO.getDesc());
        sightDetail.setSuggest(sightDetailPO.getSuggest());
        sightDetail.setTicketInfo(sightDetailPO.getTicketInfo());
        sightDetail.setOpenTime(sightDetailPO.getOpenTime());
        sightDetail.setExtra(sightDetailPO.getExtra());
        return sightDetail;
    }

    private static SightInfoDO.SightBase convertToSightBaseBO(SightBasePO sightBasePO) {
        if (sightBasePO == null) {
            return null;
        }
        SightInfoDO.SightBase sightBase = new SightInfoDO.SightBase();
        sightBase.setProvince(sightBasePO.getProvince());
        sightBase.setCity(sightBasePO.getCity());
        sightBase.setAddress(sightBasePO.getAddress());
        sightBase.setScore(sightBasePO.getScore());
        sightBase.setIsShow(sightBasePO.getIsShow());
        sightBase.setIsOpen(sightBasePO.getIsOpen());
        sightBase.setHot(sightBasePO.getHot());
        sightBase.setMainImg(sightBasePO.getMainImg());
        sightBase.setSource(sightBasePO.getSource());
        sightBase.setTitle(sightBasePO.getTitle());
        sightBase.setSlogan(sightBasePO.getSlogan());
        sightBase.setPoiId(sightBasePO.getPoiId());
        sightBase.setExtra(sightBasePO.getExtra());
        return sightBase;
    }

    public static SightBasePO builderSightBasePO(SightInfoDO sightInfoDO) {
        if (sightInfoDO == null) {
            return null;
        }
        SightInfoDO.SightBase sightBase = sightInfoDO.getSightBase();
        SightBasePO sightBasePO = new SightBasePO();
        sightBasePO.setId(sightInfoDO.getId());
        sightBasePO.setProvince(sightBase.getProvince());
        sightBasePO.setCity(sightBase.getCity());
        sightBasePO.setAddress(sightBase.getAddress());
        sightBasePO.setScore(sightBase.getScore());
        sightBasePO.setIsShow(sightBase.getIsShow());
        sightBasePO.setIsOpen(sightBase.getIsOpen());
        sightBasePO.setHot(sightBase.getHot());
        sightBasePO.setMainImg(sightBase.getMainImg());
        sightBasePO.setSource(sightBase.getSource());
        sightBasePO.setTitle(sightBase.getTitle());
        sightBasePO.setSlogan(sightBase.getSlogan());
        sightBasePO.setPoiId(sightBase.getPoiId());
        sightBasePO.setExtra(sightBase.getExtra());
        sightBasePO.setCreateUser(sightInfoDO.getCreateUser());
        sightBasePO.setLastUpdateUser(sightInfoDO.getLastUpdateUser());
        sightBasePO.setIsDelete(0);
        sightBasePO.setCreateTime(new Date());
        sightBasePO.setUpdateTime(new Date());
        return sightBasePO;
    }

    public static SightDetailPO builderSightDetailPO(SightInfoDO sightInfoDO) {
        if (sightInfoDO == null) {
            return null;
        }
        SightInfoDO.SightDetail sightDetail = sightInfoDO.getSightDetail();
        SightDetailPO sightDetailPO = new SightDetailPO();
        sightDetailPO.setId(sightInfoDO.getId());
        sightDetailPO.setDesc(sightDetail.getDesc());
        sightDetailPO.setSuggest(sightDetail.getSuggest());
        sightDetailPO.setTicketInfo(sightDetail.getTicketInfo());
        sightDetailPO.setOpenTime(sightDetail.getOpenTime());
        sightDetailPO.setExtra(sightDetail.getExtra());
        sightDetailPO.setIsDelete(0);
        sightDetailPO.setCreateTime(new Date());
        sightDetailPO.setUpdateTime(new Date());
        return sightDetailPO;
    }
}
